//
//  NewsCell.m
//  Notice
//
//  Created by CPX on 2018/8/21.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "NewsCell.h"

/**
 系统通知Cell
 */
@interface NewsCell()
@property (nonatomic,strong) UIImageView *bgView;
@property (nonatomic,strong) UILabel *titleLabel;
//@property (nonatomic,strong) UIView *dot;
@property (nonatomic,strong) UILabel *contentLabel;
@property (nonatomic,strong) UILabel *dateLabel;

@end

@implementation NewsCell

- (void)setData:(NewsModel *)data{
    _data = data;
    
    self.titleLabel.text = data.title;
    self.dateLabel.text = data.dateStr;
    self.contentLabel.text = data.content;
}

#pragma mark - lazy load

- (UIImageView*)bgView{
    if (!_bgView) {
        _bgView = [UIImageView new];
        _bgView.userInteractionEnabled = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        UIImage *image = [[UIImage imageNamed:@"shadow_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(4, 5, 8, 8) resizingMode:UIImageResizingModeStretch];
        //        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.image = image;
        [self.contentView addSubview:_bgView];
        self.contentView.backgroundColor = UIColorHex(#f4f4f4);
        [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.mas_equalTo(16);
            make.trailing.mas_equalTo(-16);
            make.top.mas_equalTo(16);
            make.bottom.mas_equalTo(0);
        }];
    }
    return _bgView;
}

- (UILabel*)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.textColor = UIColorHex(#00732F);
        _titleLabel.numberOfLines = 1;
        [self.bgView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.bgView).offset(10.5);
            make.leading.mas_equalTo(self.bgView).offset(12.5);
            make.trailing.mas_equalTo(-10);
            make.height.mas_greaterThanOrEqualTo(10);
        }];
    }
    return _titleLabel;
}

//- (UIView*)dot{
//    if (!_dot) {
//        _dot = [[UIView alloc] init];
//        [self.bgView addSubview:_dot];
//        [_dot mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.size.mas_equalTo(CGSizeMake(5, 5));
//            make.trailing.mas_equalTo(-10);
//            make.top.mas_equalTo(8);
//        }];
//    }
//    return _dot;
//}

- (UILabel*)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [UILabel new];
        _contentLabel.font = [UIFont systemFontOfSize:15];
        _contentLabel.textColor = UIColorHex(#292929);
        _contentLabel.numberOfLines = 0;
        [self.bgView addSubview:_contentLabel];
        [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.dateLabel.mas_bottom).offset(9);
            make.leading.mas_equalTo(self.bgView).offset(12.5);
            make.trailing.mas_equalTo(0);
            make.height.mas_greaterThanOrEqualTo(10);
            make.bottom.mas_equalTo(self.bgView.mas_bottom).offset(-8);
        }];
    }
    return _contentLabel;
}

- (UILabel*)dateLabel{
    if (!_dateLabel) {
        _dateLabel = [UILabel new];
        _dateLabel.font = [UIFont systemFontOfSize:11];
        _dateLabel.textColor = UIColorHex(#929292);
        _dateLabel.numberOfLines = 0;
        [self.bgView addSubview:_dateLabel];
        [_dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(3);
            make.leading.mas_equalTo(self.bgView).offset(12.5);
            make.trailing.mas_equalTo(0);
            make.height.mas_greaterThanOrEqualTo(10);
        }];
    }
    return _dateLabel;
}

@end
